/**
 *  编辑页
 *
 * 作者 zhangwei
 * 日期 2024-09-03 13:16:21
 */
layui.use(['jquery','febs', 'form', 'validate'], function () {
    var $ = layui.$,
        febs = layui.febs,
        layer = layui.layer,
        form = layui.form,
        $view = $('#incentiveQuotaApplyAudit-edit'),
        validate = layui.validate;

    form.verify(validate);
    form.render();
    initFormValue();

    function initFormValue() {
        if (incentiveQuotaApplyData) {
            form.val("incentiveQuotaApplyAudit-edit-form", {
                "quotaApplyId": incentiveQuotaApplyData.quotaApplyId,
                "tenantId": incentiveQuotaApplyData.tenantId,
                "quotaApplyNo": incentiveQuotaApplyData.quotaApplyNo,
                "year": incentiveQuotaApplyData.year,
                "userId": incentiveQuotaApplyData.userId,
                "userNo": incentiveQuotaApplyData.userNo,
                "realName": incentiveQuotaApplyData.realName,
                "deptId": incentiveQuotaApplyData.deptId,
                "deptName": incentiveQuotaApplyData.deptName,
                "applyQuota": incentiveQuotaApplyData.applyQuota,
                "factQuota": incentiveQuotaApplyData.factQuota,
                "applyRemark": incentiveQuotaApplyData.applyRemark,
                "auditUserId": incentiveQuotaApplyData.auditUserId,
                "auditRealName": incentiveQuotaApplyData.auditRealName,
                "auditDate": incentiveQuotaApplyData.auditDate,
                "status": incentiveQuotaApplyData.status,
                "auditStatus":incentiveQuotaApplyData.status == '4'? '0':'1'
            });
        }
    }

    form.on('submit(incentiveQuotaApplyAudit-edit-form-submit)', function (data) {
        audit(data.field);
        return false;
    });

    function audit(data) {
        console.log(data);
        febs.modal.confirm("审核提示！","是否审核？",function (index){
            if (data.quotaApplyId && data.quotaApplyId.length > 0) {
                febs.postArray(ctx + 'incentiveQuotaApply/auditApply', data, function () {
                    layer.closeAll();
                    febs.alert.success('审核成功');
                    $('#febs-incentiveQuotaApplyAudit').find('#query').trigger('click');
                });
            }
        })
    }
});